package net.dgg.rz.production.controller;

import net.dgg.framework.tac.utils.bean.DggRestResponse;
import net.dgg.framework.tac.utils.web.commmon.DggBaseController;
import net.dgg.rz.common.utils.ExcelTool;
import net.dgg.rz.production.entity.dto.OrderCountDto;
import net.dgg.rz.production.service.AllOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

/**
 * 生产统计
 * Created by zyou on 2019/1/4.
 */
@Controller
@RequestMapping("/rzsc_count")
public class ScCountController extends DggBaseController {

    @Autowired
    private AllOrderService allorderservice;

    /**
     * <p>@Description 跳转到生产统计页面</p>
     * <p>@author zyou</p>
     */
    @RequestMapping("/sc_count")
    public String scCount() {
        return "rzsc/count/sc_count";
    }


    /**
     * <p>@Description 获取生产统计数据</p>
     * <p>@author zyou</p>
     */
    @RequestMapping("/sc_order_count_data")
    @ResponseBody
    public DggRestResponse scOrderCountData(@RequestParam Map params) {
        Map map = allorderservice.scOrderCountData(params);
        return this.getSuccessResponse(map);
    }

    /**
     * <p>@Description 导出</p>
     * <p>@author mqy</p>
     * <p>@Time 2018/11/7 0007 15:28 创建时间</p>
     * <p>@return</p>
     */
    @RequestMapping("/export_order_count_data")
    @ResponseBody
    public void exportOrderCountData(@RequestParam Map params) {
        int[] widths = new int[] { 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8, 512*8};
        int[] styleArr = new int[] { -1, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0, 0};
        List<OrderCountDto> list = allorderservice.exportOrderCountData(params);
        String sheetName  = "融资生产数据统计";
        String[] title = new String[]{"事业部","待分配","待接收","办理中","已暂缓","退单待审核","废单待审核","退单驳回","废单驳回","已退单","已废单","生产完结","合计"};
        String[] keyArray = new String[] {"productOrgName", "waitAllotCount","waitReceiveCount","inprocessCount","suspendCount","tddshCount","fddshCount","tdbhCount","fdbhCount","ytdCount","yfdCount","scwjCount","total"};
        ExcelTool.execlExport(list,sheetName,title,keyArray,widths,styleArr);
    }

}
